/************************************************************************************
* SLDbUpdater.h                                                                     *
*                                                                                   *
* Copyright (C) 2011 Varuna L Amachi                                                *
*                                                                                   *
* This program is free software; you can redistribute it and/or modify              *
* it under the terms of the GNU General Public License as published by              *
* the Free Software Foundation; either version 2 of the License, or any             *
* later version.                                                                    *
*                                                                                   *
* This program is distributed in the hope that it will be useful, but               *
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY        *
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for       *
* more details. You should have received a copy of the GNU General Public           *
* License along with this program; if not, write to the Free Software Foundation,   *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                       *
*                                                                                   *
*************************************************************************************/

#ifndef SLDBUPDATER_H
#define SLDBUPDATER_H

#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSet>

#include "interfaces/IDbUpdater.h"


class SLDbUpdater : public IDbUpdater
{
     QSqlQuery *getQuery(QSqlDatabase *database);
     QSet<QString>* getTagsFor(CollectorItem* item);
     bool updateTagFor(CollectorItem *item, QSet<QString> *tags, QSqlDatabase *database);

public:
    SLDbUpdater();

    bool addPlaylistInfo(QString playlistName, QSqlDatabase *database = NULL);
    bool addPlaylistItem(QString playlistName, QString trackId, QSqlDatabase *database = NULL);
    bool addCollectionItem(CollectorItem *item, QSqlDatabase *database = NULL);
    bool addCollectionItems(QList<CollectorItem*> &collectionItem, QSqlDatabase *database = NULL);
//    bool addRecentAdditions(QList<CollectorItem*> &item, QSqlDatabase *database = NULL);
    bool addRecentAddition(CollectorItem *item, QSqlDatabase *database = NULL);
    bool addHistory(CollectorItem *item, QSqlDatabase *database = NULL);
    bool addSetting(QString key, QString value, QSqlDatabase *database = NULL);

    bool clearCollection(QSqlDatabase *database = NULL);
    bool clearHistory(QSqlDatabase *database = NULL);
    bool clearRecentAddtions(QSqlDatabase *database = NULL);

    bool removeHistoryItems(QList<QString>& ids, QSqlDatabase *databse = NULL);
    bool removeRecentAdditionItem(QList<QString>& ids, QSqlDatabase *databse = NULL);
    bool removePlaylistItem(QString playlist, QString trackId, QSqlDatabase *database = NULL);
    bool removeCollectionItem(QString trackId, QSqlDatabase *database = NULL);
    bool removeCollectionItems(QList<QString>* trackIds, QSqlDatabase *database = NULL);
    bool removePlaylist(QString playlistName, QSqlDatabase *database = NULL);
    bool removeTagFromItem(QString tag, CollectorItem *item, QSqlDatabase *database = NULL);

    bool attachTagToItem(QString tagName, CollectorItem *item, QSqlDatabase *database = NULL);
    bool updateTrackRating(CollectorItem *item, int rating, QSqlDatabase *database = NULL);
    bool incrementPlayCount(CollectorItem *item, QSqlDatabase *database = NULL);
    bool updatePlaylistInfo(SavedPlaylist *pl, QSqlDatabase *database = NULL);
    bool updateCollectionInfo(CollectorItem *item, QSqlDatabase *database = NULL);
};

#endif // SLDBUPDATER_H
